package com.lcx.plugin.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 内部映射枚举
 * eg：字段 -> field
 *
 * @author daxiong
 * @date 2023/6/15 上午9:56
 */
@Getter
@AllArgsConstructor
public enum FieldMatchType {
    //
    FIELD("字段", "field", 0),
    NAME("名称", "name", 1),
    TYPE("类型", "type", 2),
    LENGTH("长度", "length", 3),
    MUST("必填", "must", 4),
    MEMO("备注", "memo", 5),
    INDEX_TYPE("索引类型", "indexType", 6),
    INDEX_NAME("索引名称", "indexName", 7),
    INDEX_NOTE("索引注释", "indexNote", 8),


    ;

    private final String fieldCh;
    private final String fieldEn;
    private final int defIndex;

    public static Map<String, String> getFieldMatchMap() {
        return Arrays.stream(values()).collect(Collectors.toMap(FieldMatchType::getFieldCh, FieldMatchType::getFieldEn));
    }

    public static Map<String, Integer> getFieldDefIndexMap() {
        return Arrays.stream(values()).collect(Collectors.toMap(FieldMatchType::getFieldEn, FieldMatchType::getDefIndex));
    }
}
